<%@ page language="java" import="java.util.*, com.zjut.an.news.manager.*, com.zjut.an.news.dao.*, com.zjut.an.webclass.manager.*, com.zjut.an.webclass.dao.*,com.zjut.an.util.tools.*,com.zjut.an.util.system.*,com.zjut.an.util.page.*,com.zjut.an.util.module.*,com.zjut.an.adplace.manager.*, com.zjut.an.ad.manager.*,com.zjut.an.adplace.dao.*, com.zjut.an.ad.dao.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>招生报名系统</title>
    <script src="css/tailwindcss.css"></script>
    <style>
        .gradient-text {
            background: linear-gradient(135deg, #1e3a8a, #3b82f6);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .news-item {
            transition: all 0.3s ease;
        }
        .news-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
        }
        .line-clamp-2 {
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
    </style>
</head>
<%
HTMLCreat html = (HTMLCreat) SpringContextUtil.getBean("HTMLCreat");
AnNewsManager manager = (AnNewsManager) SpringContextUtil.getBean("AnNewsManager");
AnWebclassManager wcmanager = (AnWebclassManager) SpringContextUtil.getBean("AnWebclassManager");
AnAdplaceManager apmanager = (AnAdplaceManager) SpringContextUtil.getBean("AnAdplaceManager");
AnAdManager admanager = (AnAdManager) SpringContextUtil.getBean("AnAdManager");
PageNumber pagemanager = (PageNumber) SpringContextUtil.getBean("PageNumber");

String pageNoString = request.getParameter("pageNumber");
int pageNo = 1;
if (pageNoString != null && pageNoString.trim().length() != 0) {
	pageNo = Integer.parseInt(pageNoString.trim());
}
String pageSizeString = request.getParameter("showItemNumber");
int pageSize = 10;
if (pageSizeString != null && pageSizeString.trim().length() != 0) {
	pageSize = Integer.parseInt(pageSizeString.trim());
}
AnNews news =new AnNews();
news.setIsrecommend("推荐");
news.setIscheck("已审");
PageModule module = manager.getDataByInstance(pageNo,pageSize,"adddate","desc",news);

 %>
<body class="bg-gray-50 min-h-screen">


    <div class="max-w-6xl mx-auto px-4 pb-8">
        <!-- 新闻列表 -->
        <div class="space-y-4">
            <%
            List list = module.getObjects();
            for(int i=0; i<list.size(); i++) {
                news = (AnNews)list.get(i);
            %>
            <div class="news-item bg-white rounded-xl shadow-lg p-6 cursor-pointer" onclick="window.location='<%=html.newslink(news) %>'">
                <div class="flex justify-between items-start mb-4">
                    <div class="flex items-center space-x-3">
                        <span class="text-sm text-gray-500"><%=news.getAnWebclass().getWcName()%></span>
                    </div>
                    <div class="text-sm text-gray-500"><%=news.getAdddate().toString().substring(0,10) %></div>
                </div>
                <h3 class="text-xl font-semibold text-gray-800 mb-3 hover:text-blue-600 transition-colors duration-300">
                    <a href="<%=html.newslink(news) %>" class="hover:underline"><%=news.getTitle() %></a>
                </h3>
                <p class="text-gray-600 mb-4 line-clamp-2">
                    <%=news.getTitle() %> - 点击查看详情
                </p>
                <div class="flex justify-between items-center">
                    <div class="text-sm text-gray-500">
                        编号: <%=news.getNeId() %>
                    </div>
                    <span class="text-blue-600 hover:text-blue-800 font-medium">阅读全文 →</span>
                </div>
            </div>
            <%} %>
        </div>

        <!-- 分页 -->
        <div class="flex justify-center mt-8">
            <div class="bg-white rounded-lg shadow-sm p-4">
                <nav class="flex items-center justify-center space-x-2">
                    <%
                    int totalPages = (int) Math.ceil((double) module.getTotal() / pageSize);
                    int startPage = Math.max(1, pageNo - 2);
                    int endPage = Math.min(totalPages, pageNo + 2);

                    // 上一页
                    if (pageNo > 1) {
                    %>
                    <a href="zs_newsclass.jsp?pageNumber=<%=pageNo-1%>&showItemNumber=<%=pageSize%>"
                       class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-md hover:bg-gray-50 hover:text-gray-700 transition-colors duration-200">
                        上一页
                    </a>
                    <% } %>

                    <%
                    // 首页
                    if (startPage > 1) {
                    %>
                    <a href="zs_newsclass.jsp?pageNumber=1&showItemNumber=<%=pageSize%>"
                       class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-md hover:bg-gray-50 hover:text-gray-700 transition-colors duration-200">
                        1
                    </a>
                    <% if (startPage > 2) { %>
                    <span class="px-3 py-2 text-sm font-medium text-gray-500">...</span>
                    <% } } %>

                    <%
                    // 中间页码
                    for (int i = startPage; i <= endPage; i++) {
                        if (i == pageNo) {
                    %>
                    <span class="px-3 py-2 text-sm font-medium text-white bg-blue-600 border border-blue-600 rounded-md cursor-default">
                        <%=i%>
                    </span>
                    <% } else { %>
                    <a href="zs_newsclass.jsp?pageNumber=<%=i%>&showItemNumber=<%=pageSize%>"
                       class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-md hover:bg-gray-50 hover:text-gray-700 transition-colors duration-200">
                        <%=i%>
                    </a>
                    <% } } %>

                    <%
                    // 尾页
                    if (endPage < totalPages) {
                        if (endPage < totalPages - 1) {
                    %>
                    <span class="px-3 py-2 text-sm font-medium text-gray-500">...</span>
                    <% } %>
                    <a href="zs_newsclass.jsp?pageNumber=<%=totalPages%>&showItemNumber=<%=pageSize%>"
                       class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-md hover:bg-gray-50 hover:text-gray-700 transition-colors duration-200">
                        <%=totalPages%>
                    </a>
                    <% } %>

                    <%
                    // 下一页
                    if (pageNo < totalPages) {
                    %>
                    <a href="zs_newsclass.jsp?pageNumber=<%=pageNo+1%>&showItemNumber=<%=pageSize%>"
                       class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-md hover:bg-gray-50 hover:text-gray-700 transition-colors duration-200">
                        下一页
                    </a>
                    <% } %>
                </nav>
            </div>
        </div>
    </div>

<script src="../plugins/assets/plugins/jquery-3.5.1.min.js" type="text/javascript"></script>

<script>
    // 添加鼠标悬停效果
    document.addEventListener('DOMContentLoaded', function() {
        const newsItems = document.querySelectorAll('.news-item');
        newsItems.forEach(item => {
            item.addEventListener('mouseenter', function() {
                this.style.boxShadow = '0 10px 25px -5px rgba(0, 0, 0, 0.1)';
                this.style.transform = 'translateY(-2px)';
            });
            item.addEventListener('mouseleave', function() {
                this.style.boxShadow = '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)';
                this.style.transform = 'translateY(0)';
            });
        });
    });
</script>
</body>

</html>
